<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="<?php echo $timer=$_GET['up_timer']; ?>"/>
<style type="text/css">

body { margin:0px; padding: 3px 0 0 0; }

</style>
</head>
<body onload="gadgets.window.adjustHeight();">

<div style="width:96%;">

<?php
$url=$_GET["up_url"];
$amount=$_GET["up_amount"];
$font=$_GET["up_font"];
$fontsize=$_GET["up_fontsize"];
$mode=$_GET["up_mode"];
$showdate=$_GET["up_showdate"];
$direction=$_GET["up_direction"];

$HOME_DIR=dirname(__FILE__)."/";  //$_SERVER["DOCUMENT_ROOT"]."/simple_rss/";

require $HOME_DIR."lastRSS.php";

// create lastRSS object
$rss = new lastRSS; 

// setup transparent cache
$rss->cache_dir = "cache/"; 
//$rss->cache_dir = $HOME_DIR."cache/"; 
$rss->cache_time = 1; // ten minutes

$result="";

// load some RSS file
if ($rs = $rss->get($url)) {

// here we can work with RSS fields

$items=array_slice($rs["items"],0,$amount);

if (isset($rs['title'])) {
    echo "<b>".$rs['title']."</b><br>";
}

foreach ($items as $item)
 {
 
 if ($showdate) 
  {
  $item["pubDate"]=date("d F, H.i",strtotime($item["pubDate"]));
  }
 else 
  $item["pubDate"] = "";

 $title = "<p style='font-style:italic;font-weight:bold;font-family:".$font.";font-size:".($fontsize)."pt;direction:".$direction."'>".$item["title"]."</p>";

 if ($mode=="titles_only")
  {
  $result.="<p style='font-family:".$font.";font-size:".$fontsize."pt;direction:".$direction."'><a href='".$item["link"]."' target=_blank><div style='display:inline;direction:ltr;unicode-bidi:bidi-override;'>".$item["pubDate"]."</div> ".$item["title"]." </a></p>\n";
  }
 else
  {

  if ($item["title"])
   {
   $result.=$title;
   }

  $result.="<p style='font-family:".$font.";font-size:".$fontsize."pt;direction:".$direction."'>".
    $item["description"]."<br><small><a href='".$item["link"].
    "' target=_blank><div style='display:inline;direction:ltr;unicode-bidi:bidi-override;'>".
    $item["pubDate"]."</div></a></small></p>\n";
  }
 }
 
$result=strtr($result,array("&lt;"=>"<","&gt;"=>">","&quot;"=>"\"","&amp;"=>"&"));
$result=iconv($rs["encoding"],"UTF-8",$result);

$result = str_replace("<a href=","<a target=\"blank\" href=",$result); 

echo $result;

}
else {
	die ('Error: RSS file not found...');
}

?>

</div>

</body>
</html>

